Skip to content

feat(model): add lazy transformers compatibility guards#4619

Draft
cuichenx wants to merge 3 commits into
mainfrom
mira/transformers-version-guards-draft
Draft

feat(model): add lazy transformers compatibility guards#4619
cuichenx wants to merge 3 commits into
mainfrom
mira/transformers-version-guards-draft

Conversation

@cuichenx

@cuichenx cuichenx commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add a Bridge-local, PEP 440-aware Transformers compatibility helper with actionable version and missing-symbol errors
  • attach optional minimum-version and required-symbol metadata to registered bridge classes, enforcing it lazily after model selection and before provider/model loading or conversion
  • narrowly translate known guarded AutoConfig architecture-recognition failures without masking network, authentication, malformed-config, or unrelated errors
  • migrate GLM-5, Qwen3.5 text/VL, and DeepSeek V4 registrations and provider imports to the new mechanism
  • add focused coverage for version parsing, dotted symbols, registration metadata, guard timing, config error handling, and fresh-process registration
  • update the adding-model-support skill with compatibility discovery, registration, lazy-import, and boundary-test requirements

Motivation

This is the guard and metadata foundation proposed in #4314. It allows package and registry discovery to remain independent of newer model-specific Transformers APIs while preserving the current global dependency range. This PR does not loosen dependency bounds.

min_transformers_version=None intentionally means that compatibility research is incomplete. It is not treated as an implicit minimum; compatibility metadata is added only where the version boundary is supported by direct evidence.

Compatibility evidence

  • GLM-5 and Qwen3.5 required symbols are absent in Transformers 5.1.0 and present in 5.2.0+, so those bridges declare >=5.2.0 with exact symbols.
  • DeepSeek V4's native config and model symbols are available and its bridge constructs with Transformers 5.8.0, while 5.7.0 produces the exact lazy guard. It therefore declares >=5.8.0.
  • The 26.06 container baseline uses Transformers 5.8.1. Disposable wheel overlays exercised exact Transformers 5.7.0 and 5.6.0 without changing project dependency bounds.
  • Every registered model family reached Bridge's loading progress path in all eligible environments. DeepSeek V4 is the only family with a newly observed version-specific pre-load incompatibility.

Validation

  • uv run pre-commit run --all-files in nvcr.io/nvidia/nemo:26.06
  • focused impacted unit tests: 87 passed on Transformers 5.8.1; 58 passed on 5.7.0; 58 passed on 5.6.0
  • scoped tests/unit_tests/models: 2783 passed on 5.8.1; 2753 passed on 5.7.0; 2753 passed on 5.6.0
  • the same three Qwen3-VL processor setup errors occurred in each broad run because of process-global auto-doc registration order; the full Qwen3-VL test file passed 10/10 in a fresh process on every version
  • public tiny-model plus repository toy/synthetic import probes covered every registered model-family directory and reached loading progress on 5.8.1, 5.7.0, and 5.6.0 where compatible
  • exact DeepSeek V4 boundary probes passed at 5.8.0 and produced the expected lazy version error at 5.7.0
  • DeepSeek V4 on the 5.8.1 baseline proceeds past Transformers compatibility, then encounters an independent pinned-MCore dsv4_hybrid layer-type mismatch
  • quick_validate.py skills/adding-model-support
  • git diff --check origin/main...HEAD

Signed-off-by: Chen Cui <chcui@nvidia.com>
@copy-pr-bot

copy-pr-bot Bot commented Jul 1, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

cuichenx added 2 commits July 1, 2026 13:35
Signed-off-by: Chen Cui <chcui@nvidia.com>
Signed-off-by: Chen Cui <chcui@nvidia.com>
@cuichenx cuichenx linked an issue Jul 1, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add lazy per-model Transformers version guards for Bridge

1 participant